package com.keke.ado.role;

import com.keke.ado.baseDao;
import com.keke.pojo.Role;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class roleDaoImpl implements roleDao{
    //获取角色列表
    public List<Role> getRoleList(Connection connection) throws SQLException {

        PreparedStatement preparedStatement=null;
        ResultSet resultSet=null;
        ArrayList<Role> roleList=new ArrayList<Role>();
        if(connection!=null){
            String sql= "select * from smbms_role";
            Object[] params = {};
            resultSet = baseDao.execute(connection, preparedStatement, resultSet, sql, params);

            while(resultSet.next()){
                Role _role=new Role();
                _role.setRoleName(resultSet.getString("roleName"));
                _role.setRoleCode(resultSet.getString("roleCode"));
                _role.setId(resultSet.getInt("id"));
                roleList.add(_role);
            }
            baseDao.close(null,preparedStatement,resultSet);
        }
        return roleList;
    }
}
